﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using olierFrm.DataBase;
using System.Configuration;
using System.Web.Routing;
using System.Web.Mvc;

namespace olierFrm.MVC
{
    public class Config
    {

        public static bool DataDictionary { get; private set; }
        public static string Cache { get; private set; }
        public static string QQwry { get; private set; }
        public Config()
        {
            ConnectionConfig cc = new ConnectionConfig();

            if (ConfigurationManager.AppSettings["DataDictionary"] != null)
            {
                DataDictionary = bool.Parse(ConfigurationManager.AppSettings["DataDictionary"]);
            }

            if (ConfigurationManager.AppSettings["Cache"] != null)
                Cache = ConfigurationManager.AppSettings["Cache"];

            if (ConfigurationManager.AppSettings["QQwry"] != null)
                QQwry = ConfigurationManager.AppSettings["QQwry"];
        }

        public void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute("AjaxPost", "AjaxPost/{SqlID}/{ToUrl}", new
            {
                controller = "Framework",
                action = "AjaxPost",
                SqlID = "",
                ToUrl = ""
            });
            routes.MapRoute("AjaxGet", "AjaxGet/{Module}/{Params}", new
            {
                controller = "Framework",
                action = "AjaxGet",
                Module = "",
                Params = ""
            });
            routes.MapRoute("Default", // Route name
                 "{controller}/{action}/{Params}", // URL with parameters new
             new
             {
                 controller = "Home",
                 action = "Index",
                 Params = UrlParameter.Optional
             }).RouteHandler = new CustomMvcRouteHandler();
        }
    }
}
